/**
 * 
 */
package org.jenkon.commons.lang.filter;

import org.jenkon.commons.lang.utils.ClassUtils;


/**
 * filter implementation for filter with instance of spezific type.
 * 
 * @author jkonopka
 * 
 * @param <T> the type of filter parameter
 */
public class InstanceOfFilter<T> implements Filter<T> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4359297057691003890L;

	private final Class<?> clazz;

	/**
	 * @param clazz the {@link Class} to check
	 */
	public InstanceOfFilter(final Class<?> clazz) {
		this.clazz = clazz;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jenkon.commons.lang.filter.Filter#accept(java.lang.Object)
	 */
	public boolean accept(final T value) {
		return ClassUtils.isInstance(clazz, value);
	}

}
